//
// Created by lenovo on 25-1-4.
//

#include <vector>
using namespace std;

class Solution
{
public:
    static int removeDuplicates(vector<int>& nums)
    {
        if(nums.empty())
        {
            return 0;
        }

        auto cur = nums.begin() + 1;
        int count = 1;
        while(cur != nums.end())
        {
            if(*cur == *(cur-1))
            {
                cur = nums.erase(cur);
            }
            else
            {
                ++cur;
                count++;
            }
        }
        return count;
    }
};